package br.net.woodstock.tickettoride.struts2.web.security;

import javax.servlet.http.HttpServletRequest;

import br.net.woodstock.tickettoride.orm.User;
import br.net.woodstock.tickettoride.orm.UserType;

public class RoleValidator implements br.net.woodstock.rockframework.web.struts2.security.RoleValidator {

	@Override
	public boolean isUserInRole(final HttpServletRequest request, final String role) {
		User user = SecurityUtils.getSessionUser();
		if (user != null) {
			UserType type = user.getType();
			if (type != null) {
				return type.name().equalsIgnoreCase(role);
			}
		}
		return false;
	}

}
